﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Validation.aspx.cs" Inherits="Validation" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Validation Testing</title>

    <script language="javascript">
        function validateDate(oSrc, args) {
            var iDay, iMonth, iYear;
            var arrValues;
            arrValues = args.Value.split("/");
            iMonth = arrValues[0];
            iDay = arrValues[1];
            iYear = arrValues[2];

            var testDate = new Date(iYear, iMonth - 1, iDay);
            if ((testDate.getDate() != iDay) ||
                (testDate.getMonth() != iMonth - 1) ||
                (testDate.getFullYear() != iYear)) {
                args.IsValid = false;
                return;
            }

            return true;
        }</script>


</head>
<body>
    <form id="form1" runat="server">
    <div id="Email">
    
        <asp:TextBox ID="textEmail" runat="server"></asp:TextBox>
&nbsp;Email&nbsp;&nbsp;&nbsp; <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="textEmail" Display="Dynamic" ErrorMessage="Email addresses must be in the correct format" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ValidationGroup="AllValidators">Invalid format!</asp:RegularExpressionValidator>
        &nbsp;&nbsp;&nbsp;
        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="textEmail" Display="Dynamic" EnableClientScript="False" Enabled="False" ErrorMessage="Email address is required" ValidationGroup="AllValidators">*</asp:RequiredFieldValidator>
        <br />
        <br />
        <asp:TextBox ID="textNumberInParty" runat="server" OnTextChanged="TextBox2_TextChanged"></asp:TextBox>
&nbsp;Number in party&nbsp;&nbsp;&nbsp; <asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="textNumberInParty" Display="Dynamic" ErrorMessage="Enter a number between  a 20 for the number of people in your party" MaximumValue="20" MinimumValue="1" Type="Integer" ValidationGroup="AllValidators">Enter a number between 1 and 20.</asp:RangeValidator>
        &nbsp;&nbsp;&nbsp;
        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="textNumberInParty" ErrorMessage="Please indicate how many people are in your party"></asp:RequiredFieldValidator>
        <br />
        <br />
        <asp:TextBox ID="textPreferredDate" runat="server"></asp:TextBox>
&nbsp;Preferred Date&nbsp;&nbsp;&nbsp; <asp:CustomValidator ID="CustomValidator1" runat="server" ControlToValidate="textPreferredDate" Display="Dynamic" ErrorMessage="Enter a date in the format m/d/yyyy." OnServerValidate="CustomValidator1_ServerValidate" ValidationGroup="AllValidators" ClientValidationFunction="validateDate" SetFocusOnError="True">Invalid date format (requires m/d/yyyy).</asp:CustomValidator>
        <br />
        <br />
        <asp:Button ID="buttonSubmit" runat="server" OnClick="buttonSubmit_Click" Text="Submit Request" ValidationGroup="AllValidators" />
        &nbsp;&nbsp;
        <asp:CheckBox ID="checkPhoneConfirmation" runat="server" AutoPostBack="True" OnCheckedChanged="checkPhoneConfirmation_CheckedChanged" Text="Confirm Reservation by telephone" />
        <br />
        <br />
        <asp:TextBox ID="textPhoneNumber" runat="server" BorderStyle="Inset" CausesValidation="True" ClientIDMode="AutoID" Enabled="False" style="margin-left: 5px"></asp:TextBox>
&nbsp; Your telephone number&nbsp;&nbsp;&nbsp;
        <asp:RegularExpressionValidator ID="validatorRegExPhoneNumber" runat="server" ControlToValidate="textPhoneNumber" Display="Dynamic" ErrorMessage="Phone number format is invalid" ValidationExpression="((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}">Invalid format</asp:RegularExpressionValidator>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:RequiredFieldValidator ID="validatorRequiredPhoneNumber" runat="server" BorderStyle="Inset" ControlToValidate="textPhoneNumber" Display="Dynamic" ErrorMessage="You must provide a phone number." ValidationGroup="AllValidators" Visible="False">*</asp:RequiredFieldValidator>
        <br />
&nbsp;&nbsp;&nbsp;
        <br />
        <asp:Label ID="labelMessage" runat="server" Text="Label"></asp:Label>
        <br />
        <br />
        <asp:ValidationSummary ID="ValidationSummary1" runat="server" ValidationGroup="AllValidators" />
        <br />
    
    </div>
    </form>
</body>
</html>
